import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { createStyleImportPlugin } from 'vite-plugin-style-import'
import path from 'path'
// https://vite.dev/config/
export default defineConfig({
  //jsx文件解析成js文件
  plugins: [react(),  createStyleImportPlugin({
    libs:[
      {
        libraryName: 'zarm',
        esModule: true,
        resolveStyle: (name) => `zarm/es/${name}/style/css`
      }
    ]
  })],
  css:{
   modules:{
    localsConvention:'dashesOnly'
   },
   preprocessorOptions:{
    less:{
      javascriptEnabled:true
    }
   }
  },
  //配置路径别名
  resolve:{
    alias:{
      //项目的物理路径
      '@':path.resolve(__dirname,'src'),
      "utils":path.resolve(__dirname,'src/utils')
    }
  },
  server:{
    proxy:{
      '/api':{
        target:'http://localhost:3000/api/',
        changeOrigin:true,
        rewrite:(path) => path.replace(/^\/api/,'')
      }
    }
  }
})
